home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Assembly / Mac68k / MANUAL / MAN8.DOC < prev    next >
Encoding:
Text File  |  1985-08-11  |  11.8 KB  |  461 lines  |  [TEXT/Anon]

  1.  
  2. MAC.68K
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                                LOCAL
  10.                                LOCAL
  11.                                LOCAL
  12.  
  13.  
  14.  
  15.  
  16.  
  17.   PURPOSE         To define unique names for use within a macro
  18.  
  19.  
  20.                definition.
  21.  
  22.  
  23.  
  24.  
  25.  
  26.   FORMAT               LOCAL  symbol1,symbol2,...symbolN
  27.  
  28.  
  29.  
  30.  
  31.  
  32.   DESCRIPTION     LOCAL must immediately follow the MACRO or MACROL
  33.  
  34.  
  35.                pseudo op. It contains a list of symbols that are to
  36.  
  37.  
  38.                be used only within the macro body. During macro
  39.  
  40.  
  41.                expansion, local symbols are replaced with a symbol
  42.  
  43.  
  44.                name of ..hhhh where hhhh is a hex number starting at
  45.  
  46.  
  47.                0000 and being incremented by one each time a local
  48.  
  49.  
  50.                symbol is generated. By generating unique names for
  51.  
  52.  
  53.                each macro call, a macro may use internal location
  54.  
  55.  
  56.                symbols or EQUs and not produce duplicate name errors
  57.  
  58.  
  59.                if called more than once.  Local symbols do not appear
  60.  
  61.  
  62.                in the symbol table and are not cross referenced.
  63.  
  64.  
  65.  
  66.  
  67.  
  68.   EXAMPLE      ZEROUT  MACRO   LOCATION,COUNT
  69.  
  70.  
  71.                        LOCAL   LOOP,EXIT
  72.  
  73.  
  74.                        MOVE    #COUNT,D0
  75.  
  76.  
  77.                        BLE.S   EXIT
  78.  
  79.  
  80.                        LEA     LOCATION,A0
  81.  
  82.  
  83.                LOOP    CLR.B   (A0)+
  84.  
  85.  
  86.                        DBF     D0,LOOP
  87.  
  88.  
  89.                EXIT    DS      0
  90.  
  91.  
  92.                        ENDM
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.                               -45-                              MAC.68K
  117.  
  118.  
  119.  
  120.                                                                 MAC.68K
  121.  
  122.  
  123.  
  124.  
  125.  
  126.                                MACRO
  127.                                MACRO
  128.                                MACRO
  129.  
  130.  
  131.  
  132.  
  133.  
  134.   PURPOSE         To define a macro.
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   FORMAT     macroname  MACRO  parameter1,parameter2,...parameterN
  141.  
  142.  
  143.  
  144.  
  145.  
  146.   DESCRIPTION     MACRO is followed by a block of code terminated by
  147.  
  148.  
  149.                an ENDM.  This block of code, called the macro body,
  150.  
  151.  
  152.                is saved and may be inserted into the program assembly
  153.  
  154.  
  155.                at any future point by using the macro name as an
  156.  
  157.  
  158.                operation code.
  159.  
  160.  
  161.  
  162.                    A macro may be defined with 0 to 127 formal
  163.  
  164.  
  165.                parameters.  The parameters are listed in the operand
  166.  
  167.  
  168.                field of the MACRO statement and are separated by
  169.  
  170.  
  171.                commas. A parameter may be any valid symbol name.
  172.  
  173.  
  174.                These parameters may appear in any instruction field
  175.  
  176.  
  177.                within the body of the macro. At macro call time, when
  178.  
  179.  
  180.                the macro name is used as an operation code, the
  181.  
  182.  
  183.                operand field contains its own list of actual
  184.  
  185.  
  186.                parameters separated by commas. The first actual
  187.  
  188.  
  189.                parameter is substituted for all occurances of the
  190.  
  191.  
  192.                first formal parameter in the macro body, the second
  193.  
  194.  
  195.                actual parameter is substituted for all appearances of
  196.  
  197.  
  198.                the second formal parameter, and so on.  The resulting
  199.  
  200.  
  201.                block of code, called the macro expansion, is inserted
  202.  
  203.  
  204.                into the assembly immediately following the macro
  205.  
  206.  
  207.                call.
  208.  
  209.  
  210.  
  211.                    Local symbols and macro parameters are recognized
  212.  
  213.  
  214.                in the macro body if they are delimited by:
  215.  
  216.  
  217.                  space  +  -  *  /  (  )  &  ,  =  "
  218.  
  219.  
  220.  
  221.                    Any actual macro parameter may be placed in
  222.  
  223.  
  224.                parenthesis. This is especially useful for passing
  225.  
  226.  
  227.                special characters such as commas or spaces. An actual
  228.  
  229.  
  230.                parameter may be null. Its macro body substitution
  231.  
  232.  
  233.                will also be null.
  234.  
  235.  
  236.  
  237.                    A symbol in the location field of a MACRO call is
  238.  
  239.  
  240.                assigned a permanent value equal to the location
  241.  
  242.  
  243.                counter prior to the macro expansion.
  244.  
  245.  
  246.  
  247.                    Macro expansions may contain calls to other macros
  248.  
  249.  
  250.                or even to the same macro.  A limit of 5 nested macro
  251.  
  252.  
  253.                calls is allowed.
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262. MAC.68K                                  -46-
  263.  
  264.  
  265.  
  266. MAC.68K
  267.  
  268.  
  269.  
  270.  
  271.  
  272.   EXAMPLES
  273.  
  274.  
  275.  
  276.         definition               call                 expansion
  277.  
  278.  
  279.  
  280.  
  281.   TEST  MACRO                    TEST                   null
  282.  
  283.  
  284.         ENDM
  285.  
  286.  
  287.  
  288.  
  289.  
  290.   ADD3  MACRO  P1,P2,P3          ADD3 7,8,9            MOVE  7,D1
  291.  
  292.  
  293.         MOVE   P1,D1                                   ADD   8,D1
  294.  
  295.  
  296.         ADD    P2,D1                                   ADD   9,D1
  297.  
  298.  
  299.         ADD    P3,D1
  300.  
  301.  
  302.         ENDM
  303.  
  304.  
  305.  
  306.  
  307.  
  308.   CADD  MACRO  P1,P2,P3          CADD 4,5              MOVE  4,D1
  309.  
  310.  
  311.         LOCAL  JTAG                                    IFS   NE,*5**,1
  312.  
  313.  
  314.         MOVE   P1,D1                                   ADD   5,D1
  315.  
  316.  
  317.         IFS    NE,*P2**,1                              IFS   EQ,***
  318.  
  319.  
  320.         ADD    P2,D1                                   BRA.S ..0000
  321.  
  322.  
  323.         IFS    EQ,*P3**                                OR    $FFFE,D1
  324.  
  325.  
  326.         BRA.S  JTAG                            ..0000  DS    0
  327.  
  328.  
  329.         ELSE
  330.  
  331.  
  332.         ADD    P3,D1             CADD 4,,6             MOVE  4,D1
  333.  
  334.  
  335.         ENDC                                           IFS   NE,***,1
  336.  
  337.  
  338.         OR     #$FFFE,D1                               IFS   EQ,*6**
  339.  
  340.  
  341.   JTAG  DS     0                                       ELSE
  342.  
  343.  
  344.         ENDM                                           ADD   6,D1
  345.  
  346.  
  347.                                                        OR    #$FFFFE,D0
  348.  
  349.  
  350.                                                ..0001  DS    0
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.                                MACROL
  359.                                MACROL
  360.                                MACROL
  361.  
  362.  
  363.  
  364.  
  365.  
  366.   PURPOSE         To define a macro.
  367.  
  368.  
  369.  
  370.  
  371.  
  372.   FORMAT     macroname  MACROL parameter1,parameter2,...parameterN
  373.  
  374.  
  375.  
  376.  
  377.  
  378.   DESCRIPTION     MACROL is similiar to macro except that on the
  379.  
  380.  
  381.                MACROL call the location field is treated as call
  382.  
  383.  
  384.                parameter 1 instead of as a location field symbol.
  385.  
  386.  
  387.                (See example for STRLEN)
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                               -47-                              MAC.68K
  395.  
  396.  
  397.  
  398.                                                                 MAC.68K
  399.  
  400.  
  401.  
  402.  
  403.  
  404.                                 MAX
  405.                                 MAX
  406.                                 MAX
  407.  
  408.  
  409.  
  410.  
  411.  
  412.   PURPOSE         To generate a redefinable symbol equal to the
  413.  
  414.  
  415.                largest value from the expression list in the operand
  416.  
  417.  
  418.                field.
  419.  
  420.  
  421.  
  422.  
  423.  
  424.   FORMAT     symbol    MAX    expression1,expression2,...expressionN
  425.  
  426.  
  427.  
  428.  
  429.  
  430.   DESCRIPTION     MAX evaluates the expressions in the operand list
  431.  
  432.  
  433.                and assigns the largest value found to the redefinable
  434.  
  435.  
  436.                symbol in the location field. All symbols used in the
  437.  
  438.  
  439.                expressions must be previously defined. If any errors
  440.  
  441.  
  442.                are encountered the symbol is not (re)defined.
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.                                 MIN
  452.                                 MIN
  453.                                 MIN
  454.  
  455.  
  456.  
  457.  
  458.   PURPOSE         To generate a redefinable symbol equal to the
  459.  
  460.  
  461.                smallest value from the expression list in the operand
  462.  
  463.  
  464.                field.
  465.  
  466.  
  467.  
  468.  
  469.  
  470.   FORMAT     symbol    MIN    expression1,expression2,...expressionN
  471.  
  472.  
  473.  
  474.  
  475.  
  476.   DESCRIPTION     MIN evaluates the expressions in the operand list
  477.  
  478.  
  479.                and assigns the smallest value found to the
  480.  
  481.  
  482.                redefinable symbol in the location field. All symbols
  483.  
  484.  
  485.                used in the expressions must be previously defined. If
  486.  
  487.  
  488.                any errors are encountered the symbol is not
  489.  
  490.  
  491.                (re)defined.
  492.  
  493.  
  494.  
  495.  
  496.  
  497.   EXAMPLES     FOO     MAX     PAGESIZE,80
  498.  
  499.  
  500.                BAZ     MIN     LENGTH1,LENGTH2,LENGTH3
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512. MAC.68K                                  -48-
  513.  
  514.  
  515.  
  516. MAC.68K
  517.  
  518.  
  519.  
  520.  
  521.  
  522.                                MODULE
  523.                                MODULE
  524.                                MODULE
  525.  
  526.  
  527.  
  528.  
  529.  
  530.   PURPOSE         To indicate a MAC.68K module assembly. The object
  531.  
  532.  
  533.                file is generated with a .MOD file extension.
  534.  
  535.  
  536.  
  537.  
  538.  
  539.   FORMAT               MODULE
  540.  
  541.  
  542.  
  543.  
  544.  
  545.   DESCRIPTION     MODULE is an initialization directive. It must
  546.  
  547.  
  548.                appear after the IDENT card but before any
  549.  
  550.  
  551.                noninitialization operation codes. MODULE generates
  552.  
  553.  
  554.                the .MOD files used with INCLUDEH.
  555.  
  556.  
  557.  
  558.                    A module may contain CPU instructions and/or data.
  559.  
  560.  
  561.                It differs from an included text file in that the
  562.  
  563.  
  564.                module is assembled prior to its use and is converted
  565.  
  566.  
  567.                from text into actual machine code. The default origin
  568.  
  569.  
  570.                address for a module is $0 and there is no associated
  571.  
  572.  
  573.                load address. Because it may be called anywhere within
  574.  
  575.  
  576.                another program, a module should use relative
  577.  
  578.  
  579.                addressing and avoid absolute addressing. A module may
  580.  
  581.  
  582.                not use DATA or BSS segments.
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.                               -49-                              MAC.68K
  617.  
  618.  
  619.  
  620.                                                                 MAC.68K
  621.  
  622.  
  623.  
  624.  
  625.  
  626.                                NOREF
  627.                                NOREF
  628.                                NOREF
  629.  
  630.  
  631.  
  632.  
  633.   PURPOSE         To disable cross references for specified symbols.
  634.  
  635.  
  636.  
  637.  
  638.   FORMAT               NOREF  symbol1,symbol2,...symbolN
  639.  
  640.  
  641.  
  642.  
  643.   DESCRIPTION     NOREF turns off cross referencing for the specified
  644.  
  645.  
  646.                symbols. Symbols in the NOREF list must be already
  647.  
  648.  
  649.                defined.
  650.  
  651.  
  652.  
  653.  
  654.   EXAMPLE              NOREF   TAG,TAG1
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                                OFFSET
  665.                                OFFSET
  666.                                OFFSET
  667.  
  668.  
  669.  
  670.  
  671.   PURPOSE         To change the assembly to an offset segment.
  672.  
  673.  
  674.  
  675.  
  676.   FORMAT               OFFSET  expression
  677.  
  678.  
  679.  
  680.  
  681.   DESCRIPTION     OFFSET switches the assembly to a null segment. It
  682.  
  683.  
  684.                is useful for defining symbols with values relative
  685.  
  686.  
  687.                (offset) to the start of a table or buffer. Any type
  688.  
  689.  
  690.                of instruction, data, or reservation op code may be
  691.  
  692.  
  693.                used. Only the symbols in an offset segment are
  694.  
  695.  
  696.                retained, any code, data, or reservation locations do
  697.  
  698.  
  699.                not appear in the object file.
  700.  
  701.  
  702.  
  703.                    The default starting offset address is zero. If
  704.  
  705.  
  706.                expression is used, the value of the expression
  707.  
  708.  
  709.                becomes the starting address for this offset segment.
  710.  
  711.  
  712.                An offset segment, like any other segment, is
  713.  
  714.  
  715.                terminated when the assembly is switched to another
  716.  
  717.  
  718.                segment with a BSS, DATA, TEXT, SECTION, or END card.
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734. MAC.68K                                  -50-
  735.  
  736.  
  737.  
  738. MAC.68K
  739.  
  740.  
  741.  
  742.  
  743.  
  744.                                OPSYN
  745.                                OPSYN
  746.                                OPSYN
  747.  
  748.  
  749.  
  750.  
  751.  
  752.   PURPOSE         To equate a new operation code to an existing operation
  753.  
  754.  
  755.                code, pseudo operation code, or macro name.
  756.  
  757.  
  758.  
  759.  
  760.  
  761.   FORMAT     newname   OPSYN  opname
  762.  
  763.  
  764.  
  765.  
  766.  
  767.   DESCRIPTION     OPSYN equates a new operation code, newname , to an
  768.  
  769.  
  770.                existing operation name. This new name is independent
  771.  
  772.  
  773.                of the existing name and is not affected by any later
  774.  
  775.  
  776.                redefinition or PURGE of the existing name.
  777.  
  778.  
  779.  
  780.  
  781.  
  782.   EXAMPLE      REPT    OPSYN   DUP
  783.  
  784.  
  785.                EJECT   OPSYN   PAGE
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.                               -51-                              MAC.68K
  825.  
  826.  
  827. 
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                               -51-